import axios from './axios'
import config from './config'

let instance = axios()

export default {
  get (url, params, headers) {
    let options = {}
    if (params) {
      options.params = params
    }
    if (headers) {
      options.headers = headers
    } else {
      options.headers = {}
    }
    // options.headers['token'] = sessionStorage.getItem('token') || ''
    return instance.get(config.Url + url, options)
  },
  post (url, params, headers) {
    let options = {}
    if (headers) {
      options.headers = headers
    } else {
      options.headers = {}
    }
    // options.headers['token'] = sessionStorage.getItem('token') || ''
    return instance.post(config.Url + url, params, options)
  },
  put (url, params, headers) {
    let options = {}
    if (headers) {
      options.headers = headers
    } else {
      options.headers = {}
    }
    // options.headers['token'] = sessionStorage.getItem('token') || ''
    return instance.put(config.Url + url, params, options)
  }
}
